package cn.glutnn.controller;



import cn.glutnn.entity.Discuss;
import cn.glutnn.entity.Result;
import cn.glutnn.entity.dto.DiscussesDTO;
import cn.glutnn.service.DiscussService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * (Discuss)表控制层
 *
 * @author msh
 * @since 2024-10-25 09:32:29
 */
@Tag(name = "评论管理模块")
@RestController
@RequestMapping("/discuss")
public class DiscussController {
    /**
     * 服务对象
     */
    @Autowired
    private DiscussService discussService;

    //查询评论electByKnowledge
    @Operation(summary = "根据知识id查询评论")
    @GetMapping("/selectByKnowledge/{id}")
    public Result<List<Discuss>> selectByKnowledge(@PathVariable("id") Integer id) {
        List<Discuss> discusses = discussService.selectByKnowledge(id);
        return new Result<>(0, "查询成功", discusses);
    }

    //新增评论
    @PostMapping("/addByKnowledge")
    @Operation(summary = "新增评论")
    public Result addDiscussByKnowledge(@RequestBody DiscussesDTO dto) {
        discussService.addDiscussByKnowledge(dto);
        return Result.success();
    }
}

